package com.wenwan.manage.controller;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wenwan.manage.service.ReportService;
import com.wenwan.manage.setting.DefaultValue;

import javax.annotation.Resource;

/**
 * 举报一篇供求文章，或者普通文章
 * 
 * @author Admin
 *
 */
@Controller
@RequestMapping(value = "/report")
public class ReportController {

	@Autowired
	private ReportService reportService;

	@ResponseBody
	@RequestMapping(value = "/select/all", method = { RequestMethod.GET })
	public Map<String, Object> selectAll(
			@RequestParam(required = false, defaultValue = DefaultValue.CURRENT_PAGE) Integer currentPage,
			@RequestParam(required = false, defaultValue = DefaultValue.PAGE_SIZE) Integer pageSize,
			@RequestParam(required = false, defaultValue = DefaultValue.FALSE) Boolean isForHandled,
			@RequestParam(required = false, defaultValue = DefaultValue.FALSE) Boolean isForHandleing) {
		return reportService.selectAll(currentPage, pageSize, isForHandled, isForHandleing);
	}

	@ResponseBody
	@RequestMapping(value = "/select/one/by/id", method = { RequestMethod.GET })
	public Map<String, Object> selectOneById(@RequestParam(required = true) String id) {
		return reportService.selectOneById(id);
	}

	@ResponseBody
	@RequestMapping(value = "/delete/one/by/id", method = { RequestMethod.POST })
	public Map<String, Object> deleteOneById(@RequestParam(required = true) String id,
			@RequestParam(required = true) String belong) {
		return reportService.deleteOneById(id, belong);
	}

	@ResponseBody
	@RequestMapping(value = "/examine", method = { RequestMethod.POST })
	public Map<String, Object> examine(@RequestParam(required = true) String examineId,
			@RequestParam(required = true) String belong, @RequestParam(required = true) Boolean isAdopt) {
		return reportService.examine(examineId, belong, isAdopt);
	}

}
